package com.douyuehan.doubao.wechatpay.jparepository;

import com.douyuehan.doubao.wechatpay.model.entity.Project;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface ProjectRepository extends JpaRepository<Project, Long> {

    @Query(value = "select cast(convert(varchar,kp_date,120) as datetime)from parking_project where id=?1", nativeQuery=true)
    String findDateByStartTime(long projectId);

    @Query(value = "select cast(convert(varchar,kp_date_end,120) as datetime)from parking_project where id=?1", nativeQuery=true)
    String findDateByEndTime(long projectId);

    @Query(value = "select cast(convert(varchar,demo_date,120) as datetime)from parking_project where id=?1", nativeQuery=true)
    String findDateByStartTime0(long projectId);

    @Query(value = "select cast(convert(varchar,demo_date_end,120) as datetime)from parking_project where id=?1", nativeQuery=true)
    String findDateByEndTime0(long projectId);

    Project findById(long projectId);

    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value = "update parking_project set contractnull_img=?2 where id=?1", nativeQuery=true)
    void updateNullContractDir(long projectId, String contractnullImg);

}
